package com.localjoycommunity.cpdj.project.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.localjoycommunity.cpdj.project.system.domain.UserCourse;
import com.localjoycommunity.cpdj.project.system.domain.vo.UserCourseVo;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Optional;

public interface UserCourseMapper extends BaseMapper<UserCourse> {
    @Select("select is_dig from user_course where user_id=#{userId} and course_id =#{courseId};")
    Optional<Integer> isDig(int userId, Long courseId);

    // 查询用户学习课程分组
    @Select("SELECT uc.user_id,count(uc.course_id) course_num,u.`name` FROM user_course as uc left join `user` as u on uc.user_id=u.id group by user_id")
    List<UserCourseVo> statisticCourse();
}
